<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 代理商信息操作</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link rel="shortcut icon" href="favicon.ico"> <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight"> 
      <div class="row">
      <form method="post" class="form-horizontal" action="" id="Myform" enctype="multipart/form-data" >
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{:lang('代理商信息设置')}</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('名称')}</label>
                            <div class="col-sm-10">
                                <input id="name" name="name" class="form-control" required="required" placeholder="{:lang('输入')}{:lang('代理商名称')}" type="text">
                            </div>
                        </div>
                         <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >{:lang('联系人')}</label>
                            <div class="col-sm-10">
                                <input id="contacts" name="contacts" required="required" class="form-control" placeholder="{:lang('输入')}{:lang('联系人姓名')}" type="text">
                            </div>
                        </div>
                         <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >{:lang('联系电话')}</label>
                            <div class="col-sm-10">
                                <input id="mobile" name="mobile" placeholder="{:lang('输入')}{:lang('联系人的手机号码')}" required="required" class="form-control" type="text" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div> 
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('企业标识')}</label>
                            <div class="col-sm-10">
                                <input id="identifying" name="identifying" placeholder="{:lang('请设置初始企业标识（只能输入英文）')}" required="required" class="form-control" type="text" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('登录账号')}</label>
                            <div class="col-sm-10">
                                <input id="username" name="username" required="required" placeholder="{:lang('请设置一个代理商管理员初始账号')}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('登录密码')}</label>
                            <div class="col-sm-10">
                                <input id="password" name="password" placeholder="{:lang('请设置一个代理商管理员的初始密码')}" required="required" class="form-control" type="password" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('选择版本')}</label>
                            <div class="col-sm-10">
                                <select data-placeholder="{:lang('选择版本')}..." class="form-control chosen-select" id="version" name="version">
                                    <option value="">{:lang('选择版本')}</option>
                                    {volist name="list" id="vo"}
                                    <option value="{$vo.id}" hassubinfo="true">{$vo.name}　{$vo.vision}　 {:lang('价格')}:{$vo.price}　</option>
                                    {/volist}   
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('输入金额')}</label>
                            <div class="col-sm-10">
                                <input id="price" name="price" placeholder="{:lang('输入金额')}" required="required" class="form-control" type="text" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>   
                        <div class="form-group" >
                            <label class="col-sm-2 control-label">{:lang('选择时长')}</label>
                            <div class="col-sm-10">
                                <select class="form-control m-b __web-inspector-hide-shortcut__" id="times" name="expiration_date">
                                    <option value="">{:lang('选择时长')}</option>
                                    <option value="1">1{:lang('月')}</option>
                                    <option value="3">3{:lang('月')}</option>
                                    <option value="6">6{:lang('月')}</option>
                                    <option value="12">12{:lang('月')}(1{:lang('年')})</option>
                                    <option value="24">24{:lang('月')}(2{:lang('年')})</option>
                                    <option value="36">36{:lang('月')}(3{:lang('年')})</option>
                                    <option value="48">48{:lang('月')}(4{:lang('年')})</option>
                                    <option value="60">60{:lang('月')}(5{:lang('年')})</option>
                                </select>
                            </div>
                        </div>
                        <h3 style="font-weight:100;">{:lang('总金额')}：<span id="totalAmount" style="color:#ff0000;">0</span> {:lang('元')}</h3>
                        <div class="hr-line-dashed"></div>    
                    </div>
                </div>
            </div>     
        </div>
        <div class="row"  style="margin-top: 23px;">
            <div class="center-block col-sm-2">
                <button type="button" class="btn btn-primary btn-block" id="submit">{:lang('提交')} </button>
            </div>      
        </div>
        </form>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/sweetalert/sweetalert.min.js"></script>
  <!-- layerDate plugin javascript -->
    <script src="{$Think.config.site.resource_url}js/plugins/layer/laydate/laydate.js"></script>
  <script type="text/javascript">
  $(function(){
    $('#version').change(function(){
        var id = $(this).val();  //获取Select选择的Value
        //alert(checkValue);
        $.ajax({
            type : 'GET',
            url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Operator/add?id='+id,
            dataType : 'json',
            async : false,
            success : function(result){
                if(result){
                    $('#price').val(result.price);
                }
            },
            
        })
    });
    $('#times').change(function(){
        var timenum = $('#times').val();
        var price = $('#price').val();
        var totalAmount = timenum * price;
        $('#totalAmount').html(totalAmount);
    })
    //更新信息
    $("#submit").click(function(){
        var name = $('#name').val();
        var contacts = $('#contacts').val();
        var mobile = $('#mobile').val();
        var username = $('#username').val();
        var identifying = $('#identifying').val();
        var password = $('#password').val();
        var time = $('#times').val();
        var version = $('#version').val();
        var price = $('#price').val();
        if(name==''){
            $('#name').focus();
            return false;
        }
        if(contacts==''){
            $('#contacts').focus();
            return false;
        }
        if(mobile==''){
            $('#mobile').focus();
            return false;
        }
        if(username==''){
            $('#username').focus();
            return false;
        }
        if(identifying==''){
            $('#identifying').focus();
            return false;
        }
        if(password==''){
            $('#password').focus();
            return false;
        }
        if(password.length<6){
            layer.msg("{:lang('密码必须大于6位')}", {icon: 2});
            $('#password').focus();
            return false;
        }
        if(version==''){
            $('#version_chosen').focus();
            return false;
        }
        if(price==''){
            $('#price').focus();
            return false;
        }
        if(time==''){
            $('#times').focus();
            return false;
        }
        var formdata = $('#Myform').serialize(); 
        $.ajax({
            type : 'POST',
            url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Operator/add',
            dataType : 'json',
            data : formdata,
            async : false,
            success : function(result){
                if(0 == result.code){
                    layer.msg(result.msg, {icon: 1});
                    parent.location.reload();
                }else{
                    layer.msg(result.msg, {icon: 5});
                }
            },
            error : function(){
                layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
            }
        })
        return true;
  });
});
$(".chosen-select").chosen({disable_search_threshold: 3});
  </script>

</body>

</html>